package com.nasarius.bank.scorecard.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.nasarius.bank.scorecard.dao.UserDAO;
import com.nasarius.bank.scorecard.domain.User;
import com.nasarius.bank.scorecard.domain.UserExample;
@Repository
public class UserDAOImpl extends SqlMapClientDaoSupport implements UserDAO {

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table users
     *
     * @ibatorgenerated Sat Apr 09 15:48:39 IST 2011
     */
	@Autowired
    public UserDAOImpl(/*@Qualifier("sqlMapClient")*/SqlMapClient sqlMapClient) {
        super();
        setSqlMapClient(sqlMapClient);
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table users
     *
     * @ibatorgenerated Sat Apr 09 15:48:39 IST 2011
     */
    public int countUserByExample(UserExample example) {
        Integer count = (Integer)  getSqlMapClientTemplate().queryForObject("users.ibatorgenerated_countByExample", example);
        return count;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table users
     *
     * @ibatorgenerated Sat Apr 09 15:48:39 IST 2011
     */
    public int deleteUserByExample(UserExample example) {
        int rows = getSqlMapClientTemplate().delete("users.ibatorgenerated_deleteByExample", example);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table users
     *
     * @ibatorgenerated Sat Apr 09 15:48:39 IST 2011
     */
    public int deleteUserByPrimaryKey(String username) {
        User key = new User();
        key.setUsername(username);
        int rows = getSqlMapClientTemplate().delete("users.ibatorgenerated_deleteByPrimaryKey", key);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table users
     *
     * @ibatorgenerated Sat Apr 09 15:48:39 IST 2011
     */
    public void insertUser(User record) {
        getSqlMapClientTemplate().insert("users.ibatorgenerated_insert", record);
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table users
     *
     * @ibatorgenerated Sat Apr 09 15:48:39 IST 2011
     */
    public void insertUserSelective(User record) {
        getSqlMapClientTemplate().insert("users.ibatorgenerated_insertSelective", record);
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table users
     *
     * @ibatorgenerated Sat Apr 09 15:48:39 IST 2011
     */
    @SuppressWarnings("unchecked")
    public List<User> selectUserByExample(UserExample example) {
        List<User> list = getSqlMapClientTemplate().queryForList("users.ibatorgenerated_selectByExample", example);
        return list;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table users
     *
     * @ibatorgenerated Sat Apr 09 15:48:39 IST 2011
     */
    public User selectUserByPrimaryKey(String username) {
        User key = new User();
        key.setUsername(username);
        User record = (User) getSqlMapClientTemplate().queryForObject("users.ibatorgenerated_selectByPrimaryKey", key);
        return record;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table users
     *
     * @ibatorgenerated Sat Apr 09 15:48:39 IST 2011
     */
    public int updateUserByExampleSelective(User record, UserExample example) {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = getSqlMapClientTemplate().update("users.ibatorgenerated_updateByExampleSelective", parms);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table users
     *
     * @ibatorgenerated Sat Apr 09 15:48:39 IST 2011
     */
    public int updateUserByExample(User record, UserExample example) {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = getSqlMapClientTemplate().update("users.ibatorgenerated_updateByExample", parms);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table users
     *
     * @ibatorgenerated Sat Apr 09 15:48:39 IST 2011
     */
    public int updateUserByPrimaryKeySelective(User record) {
        int rows = getSqlMapClientTemplate().update("users.ibatorgenerated_updateByPrimaryKeySelective", record);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table users
     *
     * @ibatorgenerated Sat Apr 09 15:48:39 IST 2011
     */
    public int updateUserByPrimaryKey(User record) {
        int rows = getSqlMapClientTemplate().update("users.ibatorgenerated_updateByPrimaryKey", record);
        return rows;
    }

    /**
     * This class was generated by Apache iBATIS ibator.
     * This class corresponds to the database table users
     *
     * @ibatorgenerated Sat Apr 09 15:48:39 IST 2011
     */
    private static class UpdateByExampleParms extends UserExample {
        private Object record;

        public UpdateByExampleParms(Object record, UserExample example) {
            super(example);
            this.record = record;
        }

        @SuppressWarnings("unused")
		public Object getRecord() {
            return record;
        }
    }
}